package com.roncoo.student.stu.controller;


import com.roncoo.student.stu.entity.Lecturer;
import com.roncoo.student.stu.entity.UserLecturerAttention;
import com.roncoo.student.stu.service.impl.UserLecturerAttentionServiceImpl;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jl
 * @since 2021-04-12
 */
@RestController
@RequestMapping("/stu/attention")
public class UserLecturerAttentionController {
    @Resource
    private UserLecturerAttentionServiceImpl userLecAtt;


    /**
     * 根据用户查询该用户的关注
     * @param userId
     * @return
     */
    @PostMapping("finduserLecAttById")
    public List<Lecturer> finduserLecAttById(Integer userId){
        return userLecAtt.finduserLecAttById(userId);
    }

    /**
     * 添加一个关注
     * @param userLecturerAttention
     * @return
     */
    @PostMapping("addAttention")
    public boolean addAttention(UserLecturerAttention userLecturerAttention){
        return userLecAtt.save(userLecturerAttention);
    }

    /**
     * 根据用户和老师查询出一条数据，判断该用户是否关注了该讲师
     * @param userLecturerAttention
     * @return
     */
    @PostMapping("findByUserAndLec")
    public boolean findByUserAndLec(UserLecturerAttention userLecturerAttention){
        return userLecAtt.findByUserAndLec(userLecturerAttention);
    }

    /**
     * 根据用户和老师查询出一条数据,删除，即取消关注
     * @param userLecturerAttention
     * @return
     */
    @PostMapping("delByUserAndLec")
    public boolean delByUserAndLec(UserLecturerAttention userLecturerAttention){
        return userLecAtt.delByUserAndLec(userLecturerAttention);
    }
}

